<?php

abstract class Common_DataTable_Summary_Abstract 
implements     Common_DataTable_Summary 
{

    private $enm_position_type = null;
    
    public function __construct() {
        $this->setPositionType(Common_DataTable_Summary::POSITION_FOOTER);
    }
    
    public function setPositionType($enm_type) {
        switch($enm_type) {
        case self::POSITION_HEADER:
        case self::POSITION_FOOTER:
            $this->enm_position_type = $enm_type;
            break;
        }
    }
    
    public function getPositionType() {
        return $this->enm_position_type;
    }
    
    public function initialise($arr_columns, $arr_groups = null) {
    }
    
    public function reviewRow($arr_row, $mix_grouping_keys = null) {
    }
    
    protected function applyVariables($arr_data, $arr_variables = array()) {
        
        if(empty($arr_variables)) {
            return $arr_data;
        }
        
        foreach($arr_data as $str_key => $mix_value) {
            if(is_string($mix_value)) {
                $arr_data[$str_key] = str_replace(
                    array_keys($arr_variables),
                    array_values($arr_variables),
                    $mix_value
                );
            }
        }
        
        return $arr_data;
    }

}
